/*
 * SystemHelper.h
 *
 *  Created on: Nov 6, 2012
 *      Author: root
 */

#ifndef _SYSTEMABLE_H_
#define _SYSTEMABLE_H_

#include <memory>

template<class System>
struct SystemSingle
{
	static std::shared_ptr<System> _module;

};

template<class System> std::shared_ptr<System> SystemSingle<System>::_module;

template<class System>
void Reg()
{
	SystemSingle<System>::_module = new System();
}

template<class System, class Core>
void Reg(Core * core)
{
	SystemSingle<System>::_module = std::shared_ptr<System>(new System(core));
}

template<class T>
std::shared_ptr<T> System()
{
	return SystemSingle<T>::_module;
}

template<class Core>
struct SystemAble
{
	Core * _core;

public:

	SystemAble(Core * core) :
			_core(core)
	{

	}

	virtual ~SystemAble()
	{

	}

public:

	virtual bool init()
	{
		return false;
	}

	virtual bool uninit()
	{
		return false;
	}

	Core * get_core()
	{
		return _core;
	}
};

#endif /* _SYSTEMABLE_H_ */
